package com.example.activitys;

import java.util.ArrayList;
import java.util.List;

import com.example.tracontroller.DriverSaveToSQL;
import com.example.tracontroller.QuerySQLData;
import com.example.tracontroller.R;



import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class SeeDrivinglicenseActivity extends Activity {
	List finalData;
	private TextView DRIVERID;
	private TextView DRIVERNAME;
	private TextView DRIVERGENDER;
	private TextView NATIONALITY;
	private TextView ADDRESS;
	private TextView BIRTHDAY;
	private TextView ISSUEDATE;
	private TextView CLASSTYPE;
	private TextView VALIDDATE;
	private TextView VALIDFOR;
	private TextView FILENUMBER;
	
	private Button scanList;
    private Button mainPage;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_see_drivinglicense);
		findViews();
		scanList.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent a = new Intent();
				a.setClass(SeeDrivinglicenseActivity.this, DealWithDriverXML.class);
				startActivity(a);
				SeeDrivinglicenseActivity.this.finish();
			}
		});
		mainPage.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent a = new Intent();
				a.setClass(SeeDrivinglicenseActivity.this, MainBtnActivity.class);
				startActivity(a);
				SeeDrivinglicenseActivity.this.finish();
			}
		});
//		Intent data = getIntent();
//		ArrayList temp = data.getCharSequenceArrayListExtra("data");
//		finalData = (List) temp.get(0);
//		System.out.println("123123"+finalData);
//		DriverSaveToSQL.saveToSQL(this, finalData);
//		DriverSaveToSQL.saveToSQLCarInfo(this, finalData);
//		DriverSaveToSQL.saveToIllegalInfo(this, finalData);
		
//		displayValues();
		
	}
    private void displayValues() {
		// TODO Auto-generated method stub
    	DRIVERID.setText(finalData.get(0).toString());
    	DRIVERNAME.setText(finalData.get(7).toString());
    	DRIVERGENDER.setText(finalData.get(8).toString());
    	NATIONALITY.setText(finalData.get(9).toString());
    	ADDRESS.setText(finalData.get(10).toString());
    	BIRTHDAY.setText(finalData.get(11).toString());
    	ISSUEDATE.setText(finalData.get(12).toString());
    	CLASSTYPE.setText(finalData.get(13).toString());
    	VALIDDATE.setText(finalData.get(14).toString());
    	VALIDFOR.setText(finalData.get(15).toString());
    	FILENUMBER.setText(finalData.get(16).toString());
	}
// 1barcode 2carno 3cartype 4color 5checkdate 6vin 7driverid 8drivername 9drivergender 10nationality 11address 12birthday 13issuedate
	// 14classtype 15validdate 16validfor 17filenumber 18score 19money
	private void findViews() {
		// TODO Auto-generated method stub
		DRIVERID = (TextView)findViewById(R.id.zhenghao);
		DRIVERNAME = (TextView)findViewById(R.id.xingming);
		DRIVERGENDER = (TextView)findViewById(R.id.xingbie);
		NATIONALITY = (TextView)findViewById(R.id.guoji);
		ADDRESS = (TextView)findViewById(R.id.zhuzhi);
		BIRTHDAY = (TextView)findViewById(R.id.chusheng);
		ISSUEDATE = (TextView)findViewById(R.id.chuci);
		CLASSTYPE = (TextView)findViewById(R.id.zhunjia);
		VALIDDATE = (TextView)findViewById(R.id.youxiaoqishi);
		VALIDFOR = (TextView)findViewById(R.id.youxiao);
		FILENUMBER = (TextView)findViewById(R.id.dangan);
		scanList = (Button)findViewById(R.id.scanlist);
		mainPage = (Button)findViewById(R.id.see_dumpmain);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_see_drivinglicense, menu);
		return true;
	}

}
